package com.ruoyi.archives.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.SecurityUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.archives.domain.SysTeacherArchives;
import com.ruoyi.archives.service.ISysTeacherArchivesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 老师个人信息Controller
 * 
 * @author gzhank
 * @date 2022-03-02
 */
@Api("老师个人信息接口")
@RestController
@RequestMapping("/archives/archives")
public class SysTeacherArchivesController extends BaseController
{
    @Autowired
    private ISysTeacherArchivesService sysTeacherArchivesService;

    /**
     * 查询老师个人信息列表
     */
    @ApiOperation("查询老师个人信息列表")
    @PreAuthorize("@ss.hasPermi('archives:archives:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysTeacherArchives sysTeacherArchives)
    {
        startPage();
        List<SysTeacherArchives> list = sysTeacherArchivesService.selectSysTeacherArchivesList(sysTeacherArchives);
        return getDataTable(list);
    }

    //@ApiOperation("查询老师个人信息列表")
    @GetMapping("/listNumber")
    public TableDataInfo listNumber(SysTeacherArchives sysTeacherArchives){
        startPage();
        List<SysTeacherArchives> list = sysTeacherArchivesService.selectListNumber(sysTeacherArchives);
        return getDataTable(list);
    }

    /**
     * 导出老师个人信息列表
     */
    @ApiOperation("导出老师个人信息列表")
    @PreAuthorize("@ss.hasPermi('archives:archives:export')")
    @Log(title = "老师个人信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysTeacherArchives sysTeacherArchives)
    {
        List<SysTeacherArchives> list = sysTeacherArchivesService.selectSysTeacherArchivesList(sysTeacherArchives);
        ExcelUtil<SysTeacherArchives> util = new ExcelUtil<SysTeacherArchives>(SysTeacherArchives.class);
        util.exportExcel(response, list, "老师个人信息数据");
    }

    /**
     * 获取老师个人信息详细信息
     */
    @ApiOperation("获取老师个人信息详细信息")
    @PreAuthorize("@ss.hasPermi('archives:archives:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(sysTeacherArchivesService.selectSysTeacherArchivesById(id));
    }

    /**
     * 新增老师个人信息
     */
    @ApiOperation("新增老师个人信息")
    @PreAuthorize("@ss.hasPermi('archives:archives:add')")
    @Log(title = "老师个人信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysTeacherArchives sysTeacherArchives)
    {
        return toAjax(sysTeacherArchivesService.insertSysTeacherArchives(sysTeacherArchives));
    }

    /**
     * 修改老师个人信息
     */
    @ApiOperation("修改老师个人信息")
    @PreAuthorize("@ss.hasPermi('archives:archives:edit')")
    @Log(title = "老师个人信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysTeacherArchives sysTeacherArchives)
    {
        return toAjax(sysTeacherArchivesService.updateSysTeacherArchives(sysTeacherArchives));
    }

    /**
     * 删除老师个人信息
     */
    @ApiOperation("删除老师个人信息")
    @PreAuthorize("@ss.hasPermi('archives:archives:remove')")
    @Log(title = "老师个人信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(sysTeacherArchivesService.deleteSysTeacherArchivesByIds(ids));
    }
}
